﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Web;
using System.Xml;
using System.Threading;
using System.Web.SessionState;

/// <summary>
///WebIM_SendHandler 的摘要说明
/// </summary>
public class WebIM_SendHandler : IHttpHandler
{
    public WebIM_SendHandler()
    {
        //
        //TODO: 在此处添加构造函数逻辑
        //
    }

    HttpContext m_Context = null;

    void IHttpHandler.ProcessRequest(HttpContext context)
    {
        m_Context = context;

        System.IO.Stream inputStream = context.Request.InputStream;
        Byte[] buffer = new Byte[inputStream.Length];
        inputStream.Read(buffer, 0, (int)inputStream.Length);
        string content = context.Request.ContentEncoding.GetString(buffer);
        Hashtable data = Utility.ParseJson(content) as Hashtable;

        Message message = MessageManagement.Instance.NewMessage(data["Receiver"] as string, data["Sender"] as string, new DateTime((DateTime.Now.Ticks / 10000) * 10000), data["Content"] as string);

        context.Response.Write(Utility.RenderJson(message));
    }

    bool IHttpHandler.IsReusable
    {
        get { return true; }
    }
}
